home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / PInterfaces / TranslationExtensions.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  6.8 KB  |  227 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        TranslationExtensions.p
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1989-1993, 1995, 1997-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT TranslationExtensions;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __TRANSLATIONEXTENSIONS__}
  27. {$SETC __TRANSLATIONEXTENSIONS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC TranslationExtensionsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __FILES__}
  37. {$I Files.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED __QUICKDRAW__}
  40. {$I Quickdraw.p}
  41. {$ENDC}
  42. {$IFC UNDEFINED __COMPONENTS__}
  43. {$I Components.p}
  44. {$ENDC}
  45.  
  46.  
  47. {$PUSH}
  48. {$ALIGN MAC68K}
  49. {$LibExport+}
  50.  
  51.  
  52. CONST
  53.     kSupportsFileTranslation    = 1;
  54.     kSupportsScrapTranslation    = 2;
  55.     kTranslatorCanGenerateFilename = 4;
  56.  
  57.  
  58. {  better names for 4-char codes }
  59.  
  60. TYPE
  61.     FileType                            = OSType;
  62.     ScrapType                            = ResType;
  63.     TranslationAttributes                = UInt32;
  64.  
  65. CONST
  66.     taDstDocNeedsResourceFork    = 1;
  67.     taDstIsAppTranslation        = 2;
  68.  
  69.  
  70.  
  71. TYPE
  72.     FileTypeSpecPtr = ^FileTypeSpec;
  73.     FileTypeSpec = RECORD
  74.         format:                    FileType;
  75.         hint:                    LONGINT;
  76.         flags:                    TranslationAttributes;                    {  taDstDocNeedsResourceFork, taDstIsAppTranslation }
  77.         catInfoType:            OSType;
  78.         catInfoCreator:            OSType;
  79.     END;
  80.  
  81.     FileTranslationListPtr = ^FileTranslationList;
  82.     FileTranslationList = RECORD
  83.         modDate:                UInt32;
  84.         groupCount:                UInt32;
  85.                                                                         {      unsigned long    group1SrcCount; }
  86.                                                                         {      unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec); }
  87.                                                                         {   FileTypeSpec    group1SrcTypes[group1SrcCount] }
  88.                                                                         {   unsigned long    group1DstCount; }
  89.                                                                         {   unsigned long    group1DstEntrySize = sizeof(FileTypeSpec); }
  90.                                                                         {   FileTypeSpec    group1DstTypes[group1DstCount] }
  91.     END;
  92.  
  93.     FileTranslationListHandle            = ^FileTranslationListPtr;
  94.  
  95.     ScrapTypeSpecPtr = ^ScrapTypeSpec;
  96.     ScrapTypeSpec = RECORD
  97.         format:                    ScrapType;
  98.         hint:                    LONGINT;
  99.     END;
  100.  
  101.     ScrapTranslationListPtr = ^ScrapTranslationList;
  102.     ScrapTranslationList = RECORD
  103.         modDate:                UInt32;
  104.         groupCount:                UInt32;
  105.                                                                         {      unsigned long        group1SrcCount; }
  106.                                                                         {      unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec); }
  107.                                                                         {   ScrapTypeSpec        group1SrcTypes[group1SrcCount] }
  108.                                                                         {   unsigned long        group1DstCount; }
  109.                                                                         {      unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec); }
  110.                                                                         {   ScrapTypeSpec        group1DstTypes[group1DstCount] }
  111.     END;
  112.  
  113.     ScrapTranslationListHandle            = ^ScrapTranslationListPtr;
  114. {  definition of callbacks to update progress dialog }
  115.     TranslationRefNum                    = LONGINT;
  116. {****************************************************************************************
  117. *
  118. * This routine sets the advertisement in the top half of the progress dialog.
  119. * It is called once at the beginning of your DoTranslateFile routine.
  120. *
  121. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  122. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  123. *                            Before returning from DoTranslateFile, you should dispose
  124. *                            of the memory.  (Normally, it is in the temp translation heap
  125. *                            so it is cleaned up for you.)
  126. *
  127. * Exit:    returns            noErr, paramErr, or memFullErr
  128. }
  129. FUNCTION SetTranslationAdvertisement(refNum: TranslationRefNum; advertisement: PicHandle): OSErr;
  130.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  131.     INLINE $7002, $ABFC;
  132.     {$ENDC}
  133.  
  134. {****************************************************************************************
  135. *
  136. * This routine updates the progress bar in the progress dialog.
  137. * It is called repeatedly from within your DoTranslateFile routine.
  138. * It should be called often, so that the user will get feedback if he tries to cancel.
  139. *
  140. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  141. *            progress    percent complete (0-100)
  142. *
  143. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  144. *            returns        noErr, paramErr, or memFullErr
  145. }
  146. FUNCTION UpdateTranslationProgress(refNum: TranslationRefNum; percentDone: INTEGER; VAR canceled: BOOLEAN): OSErr;
  147.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  148.     INLINE $7001, $ABFC;
  149.     {$ENDC}
  150.  
  151.  
  152. {  ComponentMgr selectors for routines }
  153.  
  154. CONST
  155.     kTranslateGetFileTranslationList = 0;                        {  component selectors }
  156.     kTranslateIdentifyFile        = 1;
  157.     kTranslateTranslateFile        = 2;
  158.     kTranslateGetTranslatedFilename = 3;
  159.     kTranslateGetScrapTranslationList = 10;                        {  skip to scrap routines }
  160.     kTranslateIdentifyScrap        = 11;
  161.     kTranslateTranslateScrap    = 12;
  162.  
  163.  
  164. {  Routines to implment in a file translation extension }
  165.  
  166.  
  167.  
  168. TYPE
  169. {$IFC TYPED_FUNCTION_POINTERS}
  170.     DoGetFileTranslationListProcPtr = FUNCTION(self: ComponentInstance; translationList: FileTranslationListHandle): ComponentResult;
  171. {$ELSEC}
  172.     DoGetFileTranslationListProcPtr = ProcPtr;
  173. {$ENDC}
  174.  
  175. {$IFC TYPED_FUNCTION_POINTERS}
  176.     DoIdentifyFileProcPtr = FUNCTION(self: ComponentInstance; {CONST}VAR theDocument: FSSpec; VAR docType: FileType): ComponentResult;
  177. {$ELSEC}
  178.     DoIdentifyFileProcPtr = ProcPtr;
  179. {$ENDC}
  180.  
  181. {$IFC TYPED_FUNCTION_POINTERS}
  182.     DoTranslateFileProcPtr = FUNCTION(self: ComponentInstance; refNum: TranslationRefNum; {CONST}VAR sourceDocument: FSSpec; srcType: FileType; srcTypeHint: LONGINT; {CONST}VAR dstDoc: FSSpec; dstType: FileType; dstTypeHint: LONGINT): ComponentResult;
  183. {$ELSEC}
  184.     DoTranslateFileProcPtr = ProcPtr;
  185. {$ENDC}
  186.  
  187. {$IFC TYPED_FUNCTION_POINTERS}
  188.     DoGetTranslatedFilenameProcPtr = FUNCTION(self: ComponentInstance; dstType: FileType; dstTypeHint: LONGINT; VAR theDocument: FSSpec): ComponentResult;
  189. {$ELSEC}
  190.     DoGetTranslatedFilenameProcPtr = ProcPtr;
  191. {$ENDC}
  192.  
  193.  
  194. {  Routine to implement in a scrap translation extension }
  195.  
  196. {$IFC TYPED_FUNCTION_POINTERS}
  197.     DoGetScrapTranslationListProcPtr = FUNCTION(self: ComponentInstance; list: ScrapTranslationListHandle): ComponentResult;
  198. {$ELSEC}
  199.     DoGetScrapTranslationListProcPtr = ProcPtr;
  200. {$ENDC}
  201.  
  202. {$IFC TYPED_FUNCTION_POINTERS}
  203.     DoIdentifyScrapProcPtr = FUNCTION(self: ComponentInstance; dataPtr: UNIV Ptr; dataLength: Size; VAR dataFormat: ScrapType): ComponentResult;
  204. {$ELSEC}
  205.     DoIdentifyScrapProcPtr = ProcPtr;
  206. {$ENDC}
  207.  
  208. {$IFC TYPED_FUNCTION_POINTERS}
  209.     DoTranslateScrapProcPtr = FUNCTION(self: ComponentInstance; refNum: TranslationRefNum; srcDataPtr: UNIV Ptr; srcDataLength: Size; srcType: ScrapType; srcTypeHint: LONGINT; dstData: Handle; dstType: ScrapType; dstTypeHint: LONGINT): ComponentResult;
  210. {$ELSEC}
  211.     DoTranslateScrapProcPtr = ProcPtr;
  212. {$ENDC}
  213.  
  214.  
  215.  
  216.  
  217. {$ALIGN RESET}
  218. {$POP}
  219.  
  220. {$SETC UsingIncludes := TranslationExtensionsIncludes}
  221.  
  222. {$ENDC} {__TRANSLATIONEXTENSIONS__}
  223.  
  224. {$IFC NOT UsingIncludes}
  225.  END.
  226. {$ENDC}
  227.